/**
 *
 */
package idao;

import java.sql.Connection;
import java.sql.SQLException;

/**
 * Instance of this class manages connections used by iDao.
 * Method getConnection() is used to get a connection, and returnConnection() is
 * used to return the connection back to this manager.
 * Note, implementation needs to be thread safe.
 * 
 * @author huhao
 */
public interface ConnectionManager
{

    /**
     * Gets a connection for SQL execution.
     * 
     * @return a connection object
     * @throws SQLException
     *         if an error occurs
     */
    Connection getConnection() throws DaoRuntimeException;

    /**
     * Returns a connection back to this manager.
     * 
     * @param connection
     *        the connection to be returned
     * @throws SQLException
     *         if an error occurs
     */
    void returnConnection(Connection connection) throws DaoRuntimeException;
}
